package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author 老杨
 * @version 1.0
 */
@Mapper
public interface DishMapper {
    /**
     * 判断 分类id下是否有菜品关联
     * @param id
     */
    @Select("select count(*) from dish where category_id = #{id}")
    Integer haveDish(Integer id);


    Page<DishVO> page(DishPageQueryDTO dishDTO);

    /**
     * 添加菜品
     * @param dish
     */
    @AutoFill(OperationType.INSERT)
    void add(Dish dish);


    @Select("select * from dish where id = #{id}")
    Dish getById(Long id);

    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);

    /**
     * 根据 id集合 删除 菜品
     * @param ids
     */

    void delete(List<Long> ids);
    @Select("select * from dish where category_id = #{categoryId}")
    List<Dish> list(Long categoryId);



    /**
     * 根据条件统计菜品数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);
}
